package com.freak.freakmusic.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.widget.Toast

import com.ximalaya.ting.android.opensdk.player.XmPlayerManager


class MyPlayerReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        println("MyPlayerReceiver.onReceive $intent")
        if (intent.action == "com.app.test.android.Action_Close") {
            Toast.makeText(context, "通知栏点击了关闭", Toast.LENGTH_LONG).show()
            XmPlayerManager.release()
        } else if (intent.action == "com.app.test.android.Action_PAUSE_START") {
            if (XmPlayerManager.getInstance(context).isPlaying) {
                XmPlayerManager.getInstance(context).pause()
            } else {
                XmPlayerManager.getInstance(context).play()
            }
        }
    }
}
